<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="sysDefault" />
<script type="text/javascript"
	src="${staticPath}/lib/ztree/3.5/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript"
	src="${staticPath}/lib/ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
<script src="${staticPath}/js/jquery-dialog.js" type="text/javascript"></script>
<link rel="stylesheet"
	href="${staticPath}/lib/ztree/3.5/css/zTreeStyle/zTreeStyle.css"
	type="text/css">
<script type="text/javascript">
	var id = "";
	var setting = {
		view : {
			selectedMulti : false,
			nameIsHTML : true
		},
		edit : {
			enable : true,
			showRemoveBtn : setRemoveBtn,
			showRenameBtn : false
		},
		data : {
			simpleData : {
				enable : true,
			}
		},
		callback : {
			onClick : onClick,
			beforeRemove : beforeRemove
		}
	};

	//判断为顶级节点则不显示删除按钮
	function setRemoveBtn(treeId, treeNode) {
		if (treeNode.level == 0)
			return false;
		else
			return true;
	}

	function onClick(event, treeId, treeNode, clickFlag) {
		id = treeNode.id;
		if (treeNode.level != 0) {

			var url = '${contextPath}/sys/base/contractAtt/' + id + '/listAtt';
			$("#iFrame1").attr("src", url);
		} else {

			var url = '${contextPath}/sys/base/contractAtt/' + id + '/listAtt?type=0';
			$("#iFrame1").attr("src", url);
		}

	}

	function getUrlVersionFrame(url) {
		$("#versionFrame").attr("src", url);
	}
	$(document).ready(function() {
		$.get("${contextPath}/sys/base/contractAtt/get", function(data) {
			$('#result').text(data);//直接展示JSON数据
			zNodes = eval("(" + data + ")");
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		});
	});

	function beforeRemove(treeId, treeNode) {
		var flag = confirm("确认删除 节点 -- " + treeNode.name + " 吗？")
		if (flag) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.selectNode(treeNode);
			$.get("${contextPath}/sys/base/contractAtt/" + treeNode.id
					+ "/deleteAttType", function(data) {
				$('#result').text(data);//直接展示JSON数据
				zNodes = eval("(" + data + ")");
			});
		}
		return flag;
	}

	function funform(url, target) {
		window.open(url, target);
	}
	
</script>
<style type="text/css">
.marginleft {
	margin-left: 2px;
	margin-bottom: 3px;
}

.content {
	width: 100%;
	padding: 0 0 3px;
	margin: 0;
	clear: both;
}

.pane1 {
	width: 200px;
	margin-right: 3px;
	margin-left: 3px;
	float: left;
}

.right {
	display: block;
	_width: auto;
	_float: left;
}

.left-rightsplit {
	height: 100% ； border:2px solid #9FBDD7;
}

.marginright {
	margin-right: 3px;
}

.ztree li span.button.switch.level0 {
	visibility: hidden;
	width: 1px;
}

.ztree li ul.level0 {
	padding: 0;
	background: none;
}
</style>

</head>
<body>
	<div class="content left-rightsplit">
		<div id="" class="pane1 marginleft">
			<fieldset>
				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">
							合同附件类型
							<button class="btn btn-success btn-sm pull-right" role="button"
								onclick="funform('${contextPath}/sys/base/contractAtt/add','_self');">新增</button>
						</h3>
					</div>
				</div>
				<div style="position: absolute; top: 40px;">
					<ul id="treeDemo" class="ztree"></ul>
				</div>

			</fieldset>
		</div>
		<div id="" class="right marginleft marginright">
			<div class="right-top">
				<fieldset>
					<iframe id="iFrame1" name="iFrame1" width="100%"
						style="height: 1000px" frameborder="no" border="0" marginwidth="0"
						marginheight="0" scrolling="no" allowtransparency="yes"
						src="${contextPath}/sys/base/contractAtt/0/listAtt"></iframe>
				</fieldset>
			</div>

		</div>
	</div>
</body>
</html>